package com.hex.ds.em.hcdp.gauss.analyze.script.performance.entity;

import cn.hutool.core.util.StrUtil;
import com.hex.ds.em.hcdp.basic.common.MarkMsg;
import java.util.HashMap;
import java.util.Map;

/**
 * @Package com.hex.ds.em.hcdp.gauss.analyze.script.isTmpTableDropEnd.entity
 * @ClassName IsTmpTableDropEndEntity
 * @Description 规则信息实体类-检查程序尾部是否显式删除临时表
 * @Author gj.xu
 * @Date 2024/9/13 18:44
 * @Version v2.0
 **/
public class CheckTmpTableDropEndEntity extends MarkMsg {

  public Map<String, String> tables = new HashMap<>();
  private String ruleMark = "/* [GEN-PERF-019] [性能] 检查程序尾部是否显式删除临时表 - 表名：{} */";

  @Override
  protected String ruleMark() {
    return String.join("\n", tables.values());
  }

  public String addRuleMark(String tableName) {
    return tables.put(tableName, StrUtil.format(ruleMark, tableName));
  }

  public void ifExistRemoveTable(String tableName) {
    tables.remove(tableName);
  }
}
